package com.gamecollection.snake.model.obj;

import com.gamecollection.snake.model.SnakeModel;
import com.gamecollection.snake.utils.GameUtils;

import java.awt.*;
import java.util.Random;

/**
 * 食物对象
 */
public class FoodObj extends GameObj {
    
    // 随机数生成器
    private Random r = new Random();
    
    public FoodObj() {
        super();
    }
    
    public FoodObj(Image img, int x, int y, SnakeModel model) {
        super(img, x, y, model);
    }
    
    /**
     * 获取新的食物
     */
    public FoodObj getFood() {
        return new FoodObj(GameUtils.foodImg, r.nextInt(20) * 30, (r.nextInt(19) + 1) * 30, this.model);
    }
    
    @Override
    public void paintSelf(Graphics g) {
        super.paintSelf(g);
    }
} 